package entities;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;


@Entity
@Table (name = "sectores")
public class SectorEntity implements Serializable {

	@Transient
	private static final long serialVersionUID = 1L;
	
	@Id
	private Integer id;
//	@OneToMany (cascade = CascadeType.ALL)
	@OneToMany(cascade=CascadeType.ALL,fetch=FetchType.EAGER)
	@Fetch(value = FetchMode.SUBSELECT)
	@JoinColumn (name = "idSector")
	private List <MesaEntity> mesas = new ArrayList<MesaEntity>();
//	@OneToMany (cascade = CascadeType.ALL)
	@OneToMany(cascade=CascadeType.ALL,fetch=FetchType.EAGER)
	@Fetch(value = FetchMode.SUBSELECT)
	@JoinColumn(name = "idSector")
	private List <MozoEntity> mozos = new ArrayList<MozoEntity>();
	@Column (name = "nombre")
	private String nombre;

		
	public SectorEntity() {
	}
	
	
	
	public int getIdSector() {
		return id;
	}
	public void setIdSector(Integer idSector) {
		this.id = idSector;
	}
	public List<MesaEntity> getMesas() {
		return mesas;
	}
	public void setMesas(List<MesaEntity> mesas) {
		this.mesas = mesas;
	}
	public List<MozoEntity> getMozos() {
		return mozos;
	}
	public void setMozos(List<MozoEntity> mozos) {
		this.mozos = mozos;
	}
	public String getNombre() {
		return nombre;
	}
	public void setNombre(String nombre) {
		this.nombre = nombre;
	}



	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		result = prime * result + ((mesas == null) ? 0 : mesas.hashCode());
		result = prime * result + ((mozos == null) ? 0 : mozos.hashCode());
		result = prime * result + ((nombre == null) ? 0 : nombre.hashCode());
		return result;
	}



	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		SectorEntity other = (SectorEntity) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		if (mesas == null) {
			if (other.mesas != null)
				return false;
		} else if (!mesas.equals(other.mesas))
			return false;
		if (mozos == null) {
			if (other.mozos != null)
				return false;
		} else if (!mozos.equals(other.mozos))
			return false;
		if (nombre == null) {
			if (other.nombre != null)
				return false;
		} else if (!nombre.equals(other.nombre))
			return false;
		return true;
	}
	
	
	
}